-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Groth16 prover buggy draft #463
Draft
Vindaar
wants to merge
35
commits into
master
Choose a base branch
from
groth16prover
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The code previously accidentally only return 3 for the case 5.
Otherwise when performing operations on EC points in Jacobian, depending on import these can be missing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Table of Contents
buildABC
results for A, B, C in SnarkJS vs CTTjoinABC
result SnarkJS vs CTTcoeff
,witness
also used?α1
,δ1
r
,s
As[i]
incalcAp
forwt[i] * As[i]
wt * As
This is a work in progress Groth16 prover. While there is a way to get
correct proofs, I have not fully understood why the code produces
the right result in those circumstances.
I added 3 different
{.booldefine.}
variables to run one of the threedifferent cases.
The first case
-d:CM_WN=true
is the most "natural" one. zkeycoefficients are Montgomery encoded and the witness data is treated as
being in normal representation.
The second case
-d:CM_WM=true
reads both the coefficients andwitness data as Montgomery encoded.
In the final case
-d:CMM_WN=true
we treat the zkey coefficients asdoubly Montgomery encoded and the Witness data as being in normal
rep.
Why these 3 cases?
gB.
sensible, given that everything else is.
doubly Montgomery encoded". So I tried that, to find out that
indeed that makes it work. I just don't get it.
We will now compare a selection of different intermediate results and
try to narrow down the underlying issue.
In SnarkJS we use two functions to print the values. The inbuilt
ffjavascript.toString
function, which converts values to theirnormal representation and a custom
asHex
, which prints the internaldata as hex:
(and a similar one for arrays & elliptic curve points)
Target: Match SnarkJS
toString
values exactly, because theyrepresent the normal form of the numbers. If they match we know our
numbers represent the same values.
How to compare
For SnarkJS I just added a whole bunch of stuff into my local SnarkJS
code. I can provide a diff / the whole file if someone wants to run
those.
For Constantine, all the numbers below are from running:
Compare witness data & zkey coefficients data SnarkJS vs CTT
Let's print the coefficients & witness data after reading in
SnarkJS
coefficients
witness data
Let's print coefficients and witness data for the 3 different
cases
CMWN
asHex
) up toendianness. Implies it's wrong.
toString
CMWM
toString
toString
-> implies we read the data correctly!
CMMWN
CM_WN
for witness data, matchesthat 4 of the 6 are 1.
buildABC
results for A, B, C in SnarkJS vs CTTSnarkJS output for A, B, C calculations in
buildABC1
:CTT output for A, B, C for the different cases
CMWN
endianness
are different
CMWM
CMMWN
just
coeff * witness
, does that imply that in this context theMontgomery rep
R
commutes between the two scalars?A, B, C after FFT (NTT) transformations SnarkJS vs CTT
SnarkJS:
CTT output for A, B, C after
itf
CMWN
again
CMWM
CMMWN
buildABC
were identical.joinABC
result SnarkJS vs CTTSnarkJS:
CTT output for
joinABC
CMWN
buildABC
CMWM
buildABC
was the same? join ABC shouldjust be:
A[i] * B[i] - C[i]
CMMWN
CM_WM
, so no match either.None of these match.
Proof results gA, gB, gC
Proof from SnarkJS:
CTT proofs
CMWN
joinABC logic
CMWM
CMMWN
joinABC
is different fromSnarkJS, but the same as
CM_WM
, it implies it must come fromanother occurrence of
coeff
orwitness
, where the "other"version is "correct".
Despite
joinABC
not matching, the proof forCMM_WN
does match?!Where is
coeff
,witness
also used?-> Indeed, only usage in
buildABC
witness
used?-> Calculation of
calcAp
,calcBp
,calcB1
,buildABC
and theprivate elements entering proof for gC
DONE Compare
α1
,δ1
SnarkJS
CMWN, CMWM, CMMWN are all identical here:
DONE Compare
r
,s
SnarkJS:
CTT (all cases the same):
Compare
As[i]
incalcAp
forwt[i] * As[i]
SnarkJS:
CTT (all cases the same):
Compare MSM of
wt * As
From the fact that
wt
andAs
are equivalent forCM_WM
the MSMportion of
g^A
should be identical only in that case?SnarkJS
CTT
CMWN
CMWM
CMMWM, should be the same as CMWN
So why does
CM_WM
not yield the right result if both inputs areidentical?